

###########################################################################
########## Creating the Data - HR Members      				###############
###########################################################################

data <- read.csv("UNHCR_Data_08052016.csv", sep=",", header=TRUE)
data <- data[data$hrc_member==1,]
myvars <- c("year","latentmean")
data1 <- data[myvars]
data1 <- na.omit(data1)
dim(data)

hrc1998 <- data1[data1$year==1998,]
hrc1999 <- data1[data1$year==1999,]
hrc2000 <- data1[data1$year==2000,]
hrc2001 <- data1[data1$year==2001,]
hrc2002 <- data1[data1$year==2002,]
hrc2003 <- data1[data1$year==2003,]
hrc2004 <- data1[data1$year==2004,]
hrc2005 <- data1[data1$year==2005,]
hrc2006 <- data1[data1$year==2006,]
hrc2007 <- data1[data1$year==2007,]
hrc2008 <- data1[data1$year==2008,]
hrc2009 <- data1[data1$year==2009,]
hrc2010 <- data1[data1$year==2010,]
hrc2011 <- data1[data1$year==2011,]
hrc2012 <- data1[data1$year==2012,]
hrc2013 <- data1[data1$year==2013,]

###########################################################################
########## Creating the Data - UN BUT NOT HR Members      	###############
###########################################################################


data <- read.csv("UNHCR_Data_08052016.csv", sep=",", header=TRUE)
data <- data[data$un_member==1,]
data <- data[data$hrc_member!=1,]
myvars <- c("year","latentmean")
data1 <- data[myvars]
data1 <- na.omit(data1)
dim(data)

un_hrc1998 <- data1[data1$year==1998,]
un_hrc1999 <- data1[data1$year==1999,]
un_hrc2000 <- data1[data1$year==2000,]
un_hrc2001 <- data1[data1$year==2001,]
un_hrc2002 <- data1[data1$year==2002,]
un_hrc2003 <- data1[data1$year==2003,]
un_hrc2004 <- data1[data1$year==2004,]
un_hrc2005 <- data1[data1$year==2005,]
un_hrc2006 <- data1[data1$year==2006,]
un_hrc2007 <- data1[data1$year==2007,]
un_hrc2008 <- data1[data1$year==2008,]
un_hrc2009 <- data1[data1$year==2009,]
un_hrc2010 <- data1[data1$year==2010,]
un_hrc2011 <- data1[data1$year==2011,]
un_hrc2012 <- data1[data1$year==2012,]
un_hrc2013 <- data1[data1$year==2013,]

###########################################################################
########## Graph 1 --       ###############
###########################################################################

m1998 <- mean(un_hrc1998$latentmean) 
m1999 <- mean(un_hrc1999$latentmean) 
m2000 <- mean(un_hrc2000$latentmean) 
m2001 <- mean(un_hrc2001$latentmean) 
m2002 <- mean(un_hrc2002$latentmean) 
m2003 <- mean(un_hrc2003$latentmean) 
m2004 <- mean(un_hrc2004$latentmean) 
m2005 <- mean(un_hrc2005$latentmean) 
m2006 <- mean(un_hrc2006$latentmean) 
m2007 <- mean(un_hrc2007$latentmean) 
m2008 <- mean(un_hrc2008$latentmean) 
m2009 <- mean(un_hrc2009$latentmean) 
m2010 <- mean(un_hrc2010$latentmean) 
m2011 <- mean(un_hrc2011$latentmean) 
m2012 <- mean(un_hrc2012$latentmean) 
m2013 <- mean(un_hrc2013$latentmean) 

c1998 <- mean(hrc1998$latentmean) 
c1999 <- mean(hrc1999$latentmean) 
c2000 <- mean(hrc2000$latentmean) 
c2001 <- mean(hrc2001$latentmean) 
c2002 <- mean(hrc2002$latentmean) 
c2003 <- mean(hrc2003$latentmean) 
c2004 <- mean(hrc2004$latentmean) 
c2005 <- mean(hrc2005$latentmean) 
c2006 <- mean(hrc2006$latentmean) 
c2007 <- mean(hrc2007$latentmean) 
c2008 <- mean(hrc2008$latentmean) 
c2009 <- mean(hrc2009$latentmean) 
c2010 <- mean(hrc2010$latentmean) 
c2011 <- mean(hrc2011$latentmean) 
c2012 <- mean(hrc2012$latentmean) 
c2013 <- mean(hrc2013$latentmean) 

adjust <- 0.25
y1 <- c(m1998,m1999,m2000,m2001,m2002,m2003,m2004,m2005,m2006,m2007,m2008,m2009,m2010,m2011,m2012,m2013)
x1 <- c(1998:2013)

y2 <- c(c1998,c1999,c2000,c2001,c2002,c2003,c2004,c2005,c2006,c2007,c2008,c2009,c2010,c2011,c2012,c2013)
x2 <- c(1998:2013)


par(mar=c(8,4,0.2,2),xpd=FALSE,mfrow=c(1,1),oma=c(0,0,0,0),xpd=TRUE)
plot(x1,y1,main=NA,xlab="Year",xlim=c(1998,2013),ylim=c(0.0,1.1),pch=19,col="dodgerblue",frame.plot=T,axes=F,ylab="Human Rights Score")
segments(2005.5,-0.044,2005.5,1.144,lty=2)
points(x2,y2,col="coral",pch=21)
lines(x1, y1, type = "l",col="dodgerblue",lwd=3)
lines(x2, y2, type = "l",col="coral")


x.axis <- c(1998:2013)
X <- c("'98","'99","'00","'01","'02","'03","'04","'05","'06","'07","'08","'09","'10","'11","'12","'13")
axis(1,at = x.axis,labels=X)

y.axis <- c(0.0,0.2,0.4,0.6,0.8,1.0)
Y <- c("0.00","0.20","0.40","0.60","0.80","1.00")
axis(2,at = y.axis,labels=Y)

legend(1997,-0.3, legend=c("UN Members not on Human Rights Body (''Other UN Members'')", "UN Members on Human Rights Body (''HR Members'')"), pch=c(19,21), col=c("dodgerblue", "coral"),horiz=FALSE,bty = "n",lwd=c(3,1))


